import { Message } from 'element-ui'
let messageInstance = null; //解决多次重复调用问题
export default {
    install(Vue, options) {
        Vue.prototype.$msg = (message) => {
            const isStr = Object.prototype.toString.call(message)
            let messageObj = {
                showClose: true,
                duration: 4000,
                type: 'warning',
                customClass: 'new_z_index'
            }
            if (isStr == '[object String]') {
                messageObj = {
                    ...messageObj,
                    message: message
                }
            }
            if (isStr == '[object Object]') {
                messageObj = {
                    ...messageObj,
                    ...message
                }
            }
            if (messageInstance) {
                messageInstance.close()
            }
            messageInstance = Message(messageObj)

        }

    }
}